import path from 'node:path'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { defineConfig } from 'vitepress'
import { vitepressDemoPlugin } from 'vitepress-demo-plugin'
import { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'

// https://vitepress.dev/reference/site-config
export default defineConfig({
  markdown: {
    config(md) {
      md.use(vitepressDemoPlugin)
      md.use(tabsMarkdownPlugin)
    },
  },
  vite: {
    // eslint-disable-next-line ts/ban-ts-comment
    // @ts-ignore
    plugins: [vueJsx()],
    resolve: {
      alias: {
        '@': path.resolve(__dirname, '../../src'),
        'nv-crud': path.resolve(__dirname, '../../src'),
      },
    },
    css: {
      preprocessorOptions: {
        scss: {
          api: 'modern',
        },
      },
    },
  },
  title: 'Nv Crud',
  description: 'CRUD通关秘籍，配置即编码，Vue开发者的摸鱼指南',
  themeConfig: {
    // https://vitepress.dev/reference/default-theme-config
    nav: [
      { text: '首页', link: '/' },
      { text: '文档', link: '/docs/introduction', activeMatch: '/docs/*' },
      {
        text: '组件',
        activeMatch: '/components/*',
        items: [
          { text: 'Crud', link: '/components/crud/pagination', activeMatch: '/components/crud/*' },
          { text: 'Form', link: '/components/form/preset-input', activeMatch: '/components/form/*' },
          { text: 'Other', link: '/components/other', activeMatch: '/components/other/*' },
        ],
      },
    ],

    sidebar: {
      '/docs': [
        {
          text: '介绍',
          items: [
            { text: 'Nv Crud', link: '/docs/introduction/' },
          ],
        },
        {
          text: '快速上手',
          items: [
            { text: '安装', link: '/docs/installation/' },
          ],
        },
      ],
      '/components/crud': [
        {
          text: 'Crud',
          base: '/components/crud',
          items: [
            { text: '分页', link: '/pagination/' },
            { text: '搜索', link: '/search/' },
            { text: '表格', link: '/table/' },
            { text: '操作栏', link: '/actionbar/' },
            { text: '工具栏', link: '/toolbar/' },
            { text: '布局', link: '/layout/' },
            { text: '增删改查', link: '/crud/' },
            { text: '数据字典', link: '/dict/' },
          ],
        },
      ],
      '/components/form': [
        {
          text: 'Crud',
          base: '/components/form',
          items: [
            { text: '预设组件', link: '/preset-input/' },
            { text: '分组', link: '/group/' },
            { text: '布局', link: '/layout/' },
            { text: '操作栏', link: '/actions/' },
            { text: '预览模式', link: '/view-mode/' },
            { text: '自定义组件', link: '/custom-input/' },
          ],
        },
      ],
    },

    socialLinks: [
      { icon: 'github', link: 'https://github.com/vuejs/vitepress' },
    ],
  },
})
